package com.bigdata.oss.enumd;

import cn.hutool.core.util.StrUtil;

import com.bigdata.common.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 上传选择Bucket
 */
@Getter
@AllArgsConstructor
public enum OssKeyEnum {

    /**
     * 公开访问库
     */
    OSS_STATIC("dongheng-bigdata"),

    /**
     * 加密访问库
     */
    OSS_PRIVATE("hb-trade-private"),

    /**
     * 公开访问库 OBS
     */
    OBS_STATIC("cacc"),
    ;

    private String key;

    public static OssKeyEnum getByKey(String key) {
        for (OssKeyEnum value : values()) {
            if (StrUtil.equals(key, value.getKey())) {
                return value;
            }
        }
        throw new ServiceException("Not found oss key" + key);
    }
}
